define(function(require, exports, module) {
	var User = require('account/user')

	var RegisterPage = Backbone.View.extend({
		el: $('#reg-form'),
		events: {
			"submit": "submit"
		},
		submit: function(e) {
			try {
				var url = this.$el.attr('action'),
					postData = '',
					d = {
						name: $('input[name="name"]', this.$el).val(),
						email: $('input[name="email"]', this.$el).val(),
						password: $('input[name="password"]', this.$el).val()
					}
				_.each(d, function(value, key) {
					postData += key + '=' + value + '&';
				})
				$.ajax({
					url: url,
					data: postData,
					dataType: "json",
					type: "post",
					success: function(data) {
						window.location.href = '/'
					},
					error: function(data) {
						$('#form-alert').show().html(jQuery.parseJSON(data.responseText).message)
					}
				})
			} catch(e) {
				console.log(e)
			}
			return false;
		}
	});

	var SignInPage = Backbone.View.extend({
		el: $('#sign-form'),
		events: {
			"submit": "submit"
		},
		submit: function(e) {
			try {
				var url = this.$el.attr('action'),
					postData = '',
					d = {
						email: $('input[name="email"]', this.$el).val(),
						password: $('input[name="password"]', this.$el).val()
					}
				_.each(d, function(value, key) {
					postData += key + '=' + value + '&';
				})
				$.ajax({
					url: url,
					data: postData,
					dataType: "json",
					type: "post",
					success: function(data) {
						window.location.href = '/'
					},
					error: function(data) {
						$('#form-alert').show().html(jQuery.parseJSON(data.responseText).message)
					}
				})
			} catch(e) {
				console.log(e)
			}
			return false;
		}
	});
	exports.SignInPage = SignInPage;
	exports.RegisterPage = RegisterPage;
})